<template>
  <div>
    <tabbar></tabbar>
    <div class="content">
      <p class="ms">用户捐物、捐款、参与志愿者活动等即可获取积分</p>
      <p class="buy">积分用来在积分商城换取纪念小礼物</p>
      <div class="nr">
        <van-collapse v-model="activeNames">
          <van-collapse-item name="1">
            <template #title>
              <div>个人积分</div>
            </template>
            <div class="scoreBox">
              <div class="now">
                当前积分：378
              </div>
              <div class="progress">
                <van-progress :percentage="78" stroke-width="10" />
              </div>
              <p class="need">
                还需
                <span>22</span>
                分即可升级
              </p>
              <div class="star">
                <van-rate v-model="value" :size="25" color="#ee0a24" void-icon="star" void-color="#eee" readonly />
              </div>
              <p class="xq">查看详情</p>
            </div>
          </van-collapse-item>
          <van-collapse-item title="积分规则" name="2">
            <div class="rule">
              <div class="txt">
                <p>1、关于积分：此积分只可在《三叶草公益网站》获取及使用</p>
                <p>2、获取规则：用户参与、发起公益活动，皆可获得一定的积分奖励（参与捐款、捐物一次可获取10积分奖励；参与或发起公益获得一次可获取30积分奖励）</p>
                <p>3、关于成就：用户通过积分积累即可获取星级，解锁相应成绩及称号</p>
                <p>4、积分使用：积分可用于在积分商城换取纪念小礼物</p>
                <p>5、⭐关于积分本网站享有所有解释权</p>
              </div>
            </div>
          </van-collapse-item>
        </van-collapse>
      </div>

      <div class="shop">

        <p class="tit">积分商城</p>
        <ul>
          <li v-for="item in gift" :key="item.id">
            <div class="imgBox">
              <img :src="item.image" alt="">
            </div>
            <div class="txtBox">
              <p class="name">{{item.giftName}}</p>
              <p class="scores">
                {{item.score}}
                积分
              </p>
              <p class="num">
                剩余
                {{item.num}}
              </p>
              <div class="getBtn">立即换取</div>
            </div>
          </li>

        </ul>
      </div>
    </div>
    <end></end>
  </div>
</template>
<script>
import Vue from 'vue';
import { Collapse, CollapseItem, Rate, Progress } from 'vant';
Vue.use(Rate).use(Collapse).use(CollapseItem).use(Progress);
import {getGift} from '../api/Gift'
export default {
  data () {
    return {
      activeNames: ['1','2'],
      value: 3,
      scoreData: "",
      gift: []
    };
  },
  mounted () {
     
    getGift().then(res => {
      this.gift = res.data
      // console.log(this.gift)
    }).catch(err => {
      alert(err);
    })
  }
}
</script>
<style lang="scss" scoped>
.content {
  width: 1200px;
  margin: auto;
  padding: 40px 0;
  .ms {
    text-align: center;
    padding: 0px 40px;
    font-size: 18px;
  }
  .buy {
    text-align: center;
    padding: 5px 40px;
    font-size: 14px;
    color: lightcoral;
  }
  .nr {
    width: 800px;
    border: 1px solid #ccc;
    margin: 20px auto;
    font-size: 18px;
    border-radius: 8px;
    .scoreBox {
      .now {
        font-size: 16px;
        color: #333;
        padding: 10px 20px;
      }
      .progress {
        width: 400px;
        padding: 0px 20px;
      }
      .need {
        padding: 10px 20px;
        span {
          color: red;
        }
      }
      .star {
        padding: 0px 20px;
      }
      .xq {
        padding: 20px 20px;
        color: orange;
        cursor: pointer;
      }
      .xq:hover {
        text-decoration: underline;
      }
    }
    .rule {
      .txt {
        padding: 0 20px;
        p {
          color: #777;
          padding: 5px 0;
        }
      }
    }
  }
  .shop {
    background: hsl(19, 100%, 58%);
    width: 1558px;
    height: 600px;
    margin: 60px;
    margin-left: -200px;
    margin-bottom: -40px;
    .tit {
      color: white;
      text-align: center;
      padding: 20px 80px;
      font-size: 30px;
    }
    ul {
      width: 880px;
      margin: 20px auto;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      li {
        width: 17%;
        border: 1px solid #c0c0c0;
        border-radius: 5px;
        margin-bottom: 20px;
        position: relative;
        overflow: hidden;
        cursor: pointer;
        .imgBox {
          height: 200px;
          background: #000;
          overflow: hidden;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .txtBox {
          width: 100%;
          text-align: center;
          font-size: 14px;
          position: absolute;
          bottom: -200px;
          transition: bottom 0.5s;
          background: #fff;
          opacity: 0.9;
          padding-bottom: 5px;
          .name {
            color: red;
            padding: 5px 0;
          }
          .score {
            color: #333;
            padding: 5px 0;
          }
          .num {
            color: #333;
            padding: 5px 0;
          }
          .getBtn {
            background: orange;
            width: 80px;
            border-radius: 5px;
            color: #fff;
            margin: auto;
            cursor: pointer;
            padding: 2px 0;
            font-size: 12px;
          }
          .getBtn:hover {
            color: #333;
          }
        }
      }
      li:hover .txtBox {
        bottom: 0;
      }
    }
  }
}
</style>